from flask import Blueprint, request, render_template
from flask_jwt_extended import jwt_required

from service.user_service import UserService

user_api = Blueprint("user_api", __name__)


'''
    参数：
        email(str):邮箱
        password(str):密码
    返回值：
        Result对象 其中包含data为登录成功的token令牌
'''
@user_api.route("/login", methods=["POST"])
def user_login():
    # print("login")
    data = request.get_json()
    # print(data)
    return UserService.check_psd(data)


@user_api.route("/register", methods=["POST"])
def add_user():
    return UserService.add_user(request.get_json())


@user_api.route("/info", methods=["GET"])
@jwt_required()
def info():
    return UserService.info()


@user_api.route("/upload_psd", methods=["POST"])
def upload_psd():
    return UserService.upload_psd(request.get_json())


@user_api.route("/phone", methods=["GET"])
def phone():
    return render_template("test.html")
#
#
# @user_api.route("/pc", methods=["GET"])
# def pc():
#     return render_template("pc.html")
